#include "junix.h"
using namespace std;

int main(int argc, char **argv)
{
	vector<int> vi(30);
    boost::mt19937 rng;
	boost::uniform_int<> ui(1,30);

	boost::variate_generator<boost::mt19937&, boost::uniform_int<> >
		die(rng, ui);

	generate(vi.begin(), vi.end(), die);
	sort(vi.begin(), vi.end());

	ostream_iterator<int> oit(cout, " ");
	copy(vi.begin(),vi.end(), oit);
	cout<<endl;

	for_each(vi.begin(), vi.end(),
			cout<<boost::lambda::_1<<" ");
	cout<<endl;

	for_each(vi.begin(), vi.end(),
			cout<<boost::lambda::_1+1<<" ");
	cout<<endl;

	transform(vi.begin(),vi.end(),
			vi.begin(),
			boost::lambda::bind( std::modulus<int>(),
				boost::lambda::_1,5) );

	transform(vi.begin(),vi.end(),
			vi.begin(),
			boost::bind( plus<int>(),_1,5) );

	for_each(vi.begin(),vi.end(),
			cout<<boost::lambda::_1<<" ");
	cout<<endl;
}
